
char ** commonChars(char ** A, int ASize, int* returnSize){
    char **outPut = NULL;
    char temp1[2048] = {0}, temp2[2048] = {0};
    size_t len = strlen(A[0]);

    memcpy(temp1, A[0], len);

    for (int i = 1; i < ASize; i++)
    {
        int commonLen = 0;
        char *cur = A[i];
        len = strlen(cur);
        for (size_t j = 0; j < len; j++)
        {
            int b = cur[j];
            char *p = strchr(temp1, b);
            if (p) {
                *p = '\n';
                temp2[commonLen++] = cur[j];
            }
        }

        temp1[commonLen] = 0;
        memcpy(temp1, temp2, commonLen);
        memset(temp2, 0, commonLen);
    }

    len = strlen(temp1);
    outPut = (char**)malloc(sizeof (char*) * len);
    for (size_t i = 0; i < len; ++i) {
        outPut[i] = (char*)malloc(2);
        memset(outPut[i], 0, 2);
        memcpy(outPut[i], &temp1[i], 1);
    }

    *returnSize = len;
    return outPut;
}
